<?php
/**
 * Created by PhpStorm.
 * User: asus
 * Date: 2017/9/22
 * Time: 13:04
 */

namespace Wechat\Controller;

//新各大详情页
class WebcontController extends CommonController
{
    //项目团队
    public function xiangmu()
    {

        $id = i('get.id');
        $data = M('zhuanxiangmu')->where(['id'=>$id])->find();
        $lun = explode('|',$data['thumb']);
        $save = $data['read']+1;
        //增加阅读
        M('zhuanxiangmu')->where(['id'=>$id])->save(['read'=>$save]);
        //获取用户的信息
        $user = M('wechatuser')->where(['openid'=>$data['openid']])->find();
        $find = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanxiangmu'])->find();
        $this->assign(['vo'=>$data,'v'=>$user['headimg'],'lun'=>$lun,'find'=>$find]);
        $this->display();
    }
    //其他转介
    public function qita()
    {
        $id = i('get.id');
        $data = M('zhuanqita')->where(['id'=>$id])->find();
        $lun = explode('|',$data['thumb']);
        $save = $data['read']+1;
        //增加阅读
        M('zhuanqita')->where(['id'=>$id])->save(['read'=>$save]);
        //收藏次数
        $num = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanqita'])->count();
        M('zhuanqita')->where(['id'=>$id])->save(['number'=>$num]);
        //获取用户的信息
        $user = M('wechatuser')->where(['openid'=>$data['openid']])->find();
        //判断是否已收藏
        $find = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanqita'])->find();
        $this->assign(['vo'=>$data,'v'=>$user['headimg'],'lun'=>$lun,'find'=>$find]);
        $this->display();
    }
    //租赁详情
    public function zulin()
    {
        $id = i('get.id');
        //echo $id;
        //die();
        $data = M('zhuanzulin')->where(['id'=>$id])->find();
        $lun = explode('|',$data['thumb']);
        $save = $data['read']+1;
        //增加阅读
        M('zhuanzulin')->where(['id'=>$id])->save(['read'=>$save]);
        //获取用户的信息
        $user = M('wechatuser')->where(['openid'=>$data['openid']])->find();
        //收藏次数
        $num = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanzulin'])->count();
        M('zhuanzulin')->where(['id'=>$id])->save(['number'=>$num]);
        //判断是否已收藏
        $find = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanzulin'])->find();
        //循环数据
        $this->assign(['vo'=>$data,'v'=>$user['headimg'],'lun'=>$lun,'find'=>$find]);
        $this->display();
    }
    //二手房详情
    public function ershou()
    {
        $id = i('get.id');
        //echo $id;
        //die();
        $data = M('zhuanershou')->where(['id'=>$id])->find();
        $lun = explode('|',$data['thumb']);
        $save = $data['read']+1;
        //增加阅读
        M('zhuanershou')->where(['id'=>$id])->save(['read'=>$save]);
        //获取用户的信息
        $user = M('wechatuser')->where(['openid'=>$data['openid']])->find();
        //收藏次数
        $num = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanershou'])->count();
        M('zhuanershou')->where(['id'=>$id])->save(['number'=>$num]);
        //判断是否已收藏
        $find = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanershou'])->find();
        //循环数据
        $this->assign(['vo'=>$data,'v'=>$user['headimg'],'lun'=>$lun,'find'=>$find]);
        $this->display();
    }
    //新房详情
    public function xinfang()
    {
        $id = i('get.id');
        $data = M('zhuanxinfang')->where(['id'=>$id])->find();
        $lun = explode('|',$data['thumb']);
        $save = $data['read']+1;
        //增加阅读
        M('zhuanxinfang')->where(['id'=>$id])->save(['read'=>$save]);
        //获取用户的信息
        $user = M('wechatuser')->where(['openid'=>$data['openid']])->find();
        //收藏次数
        $num = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanxinfang'])->count();
        M('zhuanxinfang')->where(['id'=>$id])->save(['number'=>$num]);
        //判断是否已收藏
        $find = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuanxinfang'])->find();
        //循环数据
        $this->assign(['vo'=>$data,'v'=>$user['headimg'],'lun'=>$lun,'find'=>$find]);
        $this->display();
    }
    //招将详情
    public function zhaojiang()
    {
        $id = i('get.id');
        //数据
        $data = M('zhuandanwei')->where(['id'=>$id])->find();
        $lun = explode('|',$data['thumb']);
        $save = $data['read']+1;
        //增加阅读
        M('zhuandanwei')->where(['id'=>$id])->save(['read'=>$save]);
        //获取用户的信息
        $user = M('wechatuser')->where(['openid'=>$data['openid']])->find();
        $mingcheng = explode('|',$data['renshu']);
        $renshu = explode('|',$data['mingcheng']);
        //判断是否已收藏
        $find = M('webshoucang')->where(['tid'=>$id,'model'=>'zhuandanwei'])->find();
        /*
        echo '<pre/>';
        var_dump($data);
        die();
        */
        //循环数据
        $this->assign(['vo'=>$data,'v'=>$user['headimg'],'lun'=>$lun,'find'=>$find,'m'=>$mingcheng,'r'=>$renshu]);
        $this->display();
    }
}